﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Reflection;
using System.Data;
using RTracker.Models.User;
using RTracker.Models.Organization;
using RTracker.Areas.Recruitment.Models.Candidate;
using RTracker.Areas.Recruitment.Models.Calling;
using RTracker.Areas.Recruitment.Models.CandidateDriveStatus;
using RTracker.Areas.Recruitment.Models.CandidateSource;
using RTracker.Areas.Recruitment.Models.Client;
using RTracker.Areas.Recruitment.Models.ContactPerson;
using RTracker.Areas.Recruitment.Models.Shift;
using RTracker.Areas.Recruitment.Models.VacancyExpirence;
using RTracker.Areas.Recruitment.Models.VacancyStatus;
using RTracker.Areas.Recruitment.Models.VacancySalary;
using RTracker.Areas.Recruitment.Models.Vacancy;


namespace RTracker.Models.Common
{
    public static class CConversionClass
    {
        private static Boolean ColContain(DataTable dt, DataRow dtRow, string colname)
        {
            Boolean res = false;
            if (dt.Columns.Contains(colname) && dtRow[colname] != DBNull.Value)
            {
                res = true;
            }
            return res;
        }
        public static List<CUser> ConvertToListFromDataTableUser(this DataTable dt)
        {
            List<CUser> lstCUser = new List<CUser>();

            foreach (DataRow dtRow in dt.Rows)
            {
                CUser objCUser = new CUser();

                if (ColContain(dt, dtRow, "user_id"))
                    objCUser.UserId = Convert.ToInt32(dtRow["user_id"]);
                if (ColContain(dt, dtRow, "organization_id"))
                    objCUser.OrganizationId = Convert.ToInt32(dtRow["organization_id"]);
                if (ColContain(dt, dtRow, "first_name"))
                    objCUser.FirstName = dtRow["first_name"].ToString();
                if (ColContain(dt, dtRow, "last_name"))
                    objCUser.LastName = dtRow["last_name"].ToString();
                if (ColContain(dt, dtRow, "dob"))
                    objCUser.DOB = Convert.ToDateTime(dtRow["dob"]);
                if (ColContain(dt, dtRow, "gender"))
                    objCUser.Gender = dtRow["gender"].ToString();
                if (ColContain(dt, dtRow, "title"))
                    objCUser.Title = dtRow["title"].ToString();
                if (ColContain(dt, dtRow, "activation_date"))
                    objCUser.ActivationDate = Convert.ToDateTime(dtRow["activation_date"]);
                if (ColContain(dt, dtRow, "expiration_date"))
                    objCUser.ExpirationDate = Convert.ToDateTime(dtRow["expiration_date"]);
                if (ColContain(dt, dtRow, "logon_name"))
                    objCUser.LogonName = dtRow["logon_name"].ToString();
                if (ColContain(dt, dtRow, "logon_password"))
                    objCUser.LogonPassword = dtRow["logon_password"].ToString();
                if (ColContain(dt, dtRow, "email_address"))
                    objCUser.EmailAddress = dtRow["email_address"].ToString();
                if (ColContain(dt, dtRow, "logon_status"))
                    objCUser.LogonStatus = Convert.ToInt32(dtRow["logon_status"]);
                if (ColContain(dt, dtRow, "password_change_timestamp"))
                    objCUser.PasswordChangeTimestamp = Convert.ToDateTime(dtRow["password_change_timestamp"]);
                if (ColContain(dt, dtRow, "user_account_status"))
                    objCUser.UserAccountStatus = Convert.ToInt32(dtRow["user_account_status"]);


                if (ColContain(dt, dtRow, "logon_locked"))
                    objCUser.LogonLocked = Convert.ToInt32(dtRow["logon_locked"]);
                if (ColContain(dt, dtRow, "logon_locked_timestamp"))
                    objCUser.LogonLockedTimestamp = Convert.ToDateTime(dtRow["logon_locked_timestamp"]);
                if (ColContain(dt, dtRow, "change_password_next_logon"))
                    objCUser.ChangePasswordNextLogon = Convert.ToBoolean(dtRow["change_password_next_logon"]);
                if (ColContain(dt, dtRow, "last_successful_logon_timestamp"))
                    objCUser.LastSuccessfulLogonTimestamp = Convert.ToDateTime(dtRow["last_successful_logon_timestamp"]);
                if (ColContain(dt, dtRow, "last_successful_logout_timestamp"))
                    objCUser.LastSuccessfulLogoutTimestamp = Convert.ToDateTime(dtRow["last_successful_logout_timestamp"]);
                if (ColContain(dt, dtRow, "logon_failure_count"))
                    objCUser.LogonFailureCount = Convert.ToInt32(dtRow["logon_failure_count"]);
                if (ColContain(dt, dtRow, "is_system_generated"))
                    objCUser.IsSystemGenerated = Convert.ToBoolean(dtRow["is_system_generated"]);
                if (ColContain(dt, dtRow, "is_soft_locked"))
                    objCUser.IsSoftLocked = Convert.ToBoolean(dtRow["is_soft_locked"]);
                if (ColContain(dt, dtRow, "soft_locked_by"))
                    objCUser.SoftLockedBy = Convert.ToInt32(dtRow["soft_locked_by"]);
                if (ColContain(dt, dtRow, "soft_lock_timestamp"))
                    objCUser.SoftLockTimestamp = Convert.ToDateTime(dtRow["soft_lock_timestamp"]);
                if (ColContain(dt, dtRow, "is_hard_locked"))
                    objCUser.IsHardLocked = Convert.ToBoolean(dtRow["is_hard_locked"]);
                if (ColContain(dt, dtRow, "hard_locked_by"))
                    objCUser.HardLockedBy = Convert.ToInt32(dtRow["hard_locked_by"]);
                if (ColContain(dt, dtRow, "hard_lock_timestamp"))
                    objCUser.HardLockTimestamp = Convert.ToDateTime(dtRow["hard_lock_timestamp"]);
                if (ColContain(dt, dtRow, "create_timestamp"))
                    objCUser.CreateTimestamp = Convert.ToDateTime(dtRow["create_timestamp"]);
                if (ColContain(dt, dtRow, "created_by"))
                    objCUser.CreatedBy = Convert.ToInt32(dtRow["created_by"]);
                if (ColContain(dt, dtRow, "modified_timestamp"))
                    objCUser.ModifiedTimestamp = Convert.ToDateTime(dtRow["modified_timestamp"]);
                if (ColContain(dt, dtRow, "modified_by"))
                    objCUser.ModifiedBy = Convert.ToInt32(dtRow["modified_by"]);
                if (ColContain(dt, dtRow, "delete_flag"))
                    objCUser.DeleteFlag = Convert.ToBoolean(dtRow["delete_flag"]);

                lstCUser.Add(objCUser);

            }
            return lstCUser;
        }

        public static List<COrganization> ConvertToListFromDataTableOrg(this DataTable dt)
        {
            List<COrganization> lstCOrg = new List<COrganization>();

            foreach (DataRow dtRow in dt.Rows)
            {
                COrganization objCOrg = new COrganization();
                if (ColContain(dt, dtRow, "organization_id"))
                    objCOrg.OrganizationId = Convert.ToInt32(dtRow["organization_id"]);
                if (ColContain(dt, dtRow, "organization_name"))
                    objCOrg.OrganizationName = dtRow["organization_name"].ToString();
                if (ColContain(dt, dtRow, "address"))
                    objCOrg.Address = dtRow["address"].ToString();
                if (ColContain(dt, dtRow, "city"))
                    objCOrg.City = dtRow["city"].ToString();
                if (ColContain(dt, dtRow, "state"))
                    objCOrg.State = dtRow["state"].ToString();
                if (ColContain(dt, dtRow, "zip"))
                    objCOrg.Zip = dtRow["zip"].ToString();
                if (ColContain(dt, dtRow, "web_site"))
                    objCOrg.WebSite = dtRow["web_site"].ToString();
                if (ColContain(dt, dtRow, "primary_email"))
                    objCOrg.PrimaryEmail = dtRow["primary_email"].ToString();
                if (ColContain(dt, dtRow, "secondary_email"))
                    objCOrg.SecondaryEmail = dtRow["secondary_email"].ToString();
                if (ColContain(dt, dtRow, "phone_number"))
                    objCOrg.PhoneNumber = dtRow["phone_number"].ToString();
                if (ColContain(dt, dtRow, "logo"))
                    objCOrg.Logo = dtRow["logo"].ToString();
                if (ColContain(dt, dtRow, "is_soft_locked"))
                    objCOrg.IsSoftLocked = Convert.ToBoolean(dtRow["is_soft_locked"].ToString());
                if (ColContain(dt, dtRow, "soft_locked_by"))
                    objCOrg.SoftLockedBy = Convert.ToInt32(dtRow["soft_locked_by"].ToString());
                if (ColContain(dt, dtRow, "soft_lock_timestamp"))
                    objCOrg.SoftLockTimestamp = Convert.ToDateTime(dtRow["soft_lock_timestamp"].ToString());
                if (ColContain(dt, dtRow, "is_hard_locked"))
                    objCOrg.IsHardLocked = Convert.ToBoolean(dtRow["is_hard_locked"].ToString());
                if (ColContain(dt, dtRow, "hard_locked_by"))
                    objCOrg.HardLockedBy = Convert.ToInt32(dtRow["hard_locked_by"].ToString());
                if (ColContain(dt, dtRow, "hard_lock_timestamp"))
                    objCOrg.HardLockTimestamp = Convert.ToDateTime(dtRow["hard_lock_timestamp"].ToString());
                if (ColContain(dt, dtRow, "create_timestamp"))
                    objCOrg.CreateTimestamp = Convert.ToDateTime(dtRow["create_timestamp"].ToString());
                if (ColContain(dt, dtRow, "created_by"))
                    objCOrg.CreatedBy = Convert.ToInt32(dtRow["created_by"].ToString());
                if (ColContain(dt, dtRow, "modified_timestamp"))
                    objCOrg.ModifiedTimestamp = Convert.ToDateTime(dtRow["modified_timestamp"].ToString());
                if (ColContain(dt, dtRow, "modified_by"))
                    objCOrg.ModifiedBy = Convert.ToInt32(dtRow["modified_by"].ToString());
                if (ColContain(dt, dtRow, "delete_flag"))
                    objCOrg.DeleteFlag = Convert.ToBoolean(dtRow["delete_flag"].ToString());

                lstCOrg.Add(objCOrg);
            }

            return lstCOrg;
        }

        public static List<CUserSession> ConvertToListFromDataTableUserSessionInfo(this DataTable dt)
        {
            List<CUserSession> lstCUsrSesInfo = new List<CUserSession>();

            foreach (DataRow dtRow in dt.Rows)
            {
                CUserSession objCUsrSesInfo = new CUserSession();
                if (ColContain(dt, dtRow, "session_key"))
                    objCUsrSesInfo.SessionKey = dtRow["session_key"].ToString();
                if (ColContain(dt, dtRow, "user_session_id"))
                    objCUsrSesInfo.UserSessionId = Convert.ToInt64(dtRow["user_session_id"].ToString());
                if (ColContain(dt, dtRow, "user_id"))
                    objCUsrSesInfo.UserId = Convert.ToInt32(dtRow["user_id"].ToString());
                if (ColContain(dt, dtRow, "organization_id"))
                    objCUsrSesInfo.OrganizationId = Convert.ToInt32(dtRow["organization_id"].ToString());
                if (ColContain(dt, dtRow, "session_start_time"))
                    objCUsrSesInfo.SessionStartTime = Convert.ToDateTime(dtRow["session_start_time"].ToString());
                if (ColContain(dt, dtRow, "session_end_time"))
                    objCUsrSesInfo.SessionEndTime = Convert.ToDateTime(dtRow["session_end_time"].ToString());
                if (ColContain(dt, dtRow, "session_status"))
                    objCUsrSesInfo.SessionStatus = Convert.ToInt32(dtRow["session_status"].ToString());
                if (ColContain(dt, dtRow, "device"))
                    objCUsrSesInfo.Device = dtRow["device"].ToString();
                if (ColContain(dt, dtRow, "ip_address"))
                    objCUsrSesInfo.IpAddress = dtRow["ip_address"].ToString();
                if (ColContain(dt, dtRow, "operating_system"))
                    objCUsrSesInfo.OperatingSystem = dtRow["operating_system"].ToString();
                if (ColContain(dt, dtRow, "application_used"))
                    objCUsrSesInfo.ApplicationUsed = dtRow["application_used"].ToString();
                if (ColContain(dt, dtRow, "version"))
                    objCUsrSesInfo.Version = dtRow["version"].ToString();
                if (ColContain(dt, dtRow, "location"))
                    objCUsrSesInfo.Location = dtRow["location"].ToString();
                if (ColContain(dt, dtRow, "create_timestamp"))
                    objCUsrSesInfo.CreateTimestamp = Convert.ToDateTime(dtRow["create_timestamp"].ToString());
                if (ColContain(dt, dtRow, "created_by"))
                    objCUsrSesInfo.CreatedBy = Convert.ToInt32(dtRow["created_by"].ToString());
                if (ColContain(dt, dtRow, "modified_timestamp"))
                    objCUsrSesInfo.ModifiedTimestamp = Convert.ToDateTime(dtRow["modified_timestamp"].ToString());
                if (ColContain(dt, dtRow, "modified_by"))
                    objCUsrSesInfo.ModifiedBy = Convert.ToInt32(dtRow["modified_by"].ToString());
                if (ColContain(dt, dtRow, "delete_flag"))
                    objCUsrSesInfo.DeleteFlag = Convert.ToBoolean(dtRow["delete_flag"].ToString());

                lstCUsrSesInfo.Add(objCUsrSesInfo);
            }
            return lstCUsrSesInfo;
        }

        public static List<CCalling> ConvertToListFromDataTableCalling(this DataTable dt)
        {
            List<CCalling> lstCCalling = new List<CCalling>();

            foreach (DataRow dtRow in dt.Rows)
            {
                CCalling objCalling = new CCalling();

                if (ColContain(dt, dtRow, "calling_id"))
                    objCalling.CallingId = Convert.ToInt32(dtRow["calling_id"]);
                if (ColContain(dt, dtRow, "calling_desc"))
                    objCalling.CallingDesc = dtRow["calling_desc"].ToString();
                if (ColContain(dt, dtRow, "client"))
                    objCalling.Client = Convert.ToInt32(dtRow["client"]);
                if (ColContain(dt, dtRow, "department"))
                    objCalling.Department = Convert.ToInt32(dtRow["department"]);
                if (ColContain(dt, dtRow, "vacancy"))
                    objCalling.Vacancy = Convert.ToInt32(dtRow["vacancy"]);
                if (ColContain(dt, dtRow, "candidate"))
                    objCalling.Candidate = Convert.ToInt32(dtRow["candidate"]);
                if (ColContain(dt, dtRow, "call_timestamp"))
                    objCalling.CallTimeStamp = Convert.ToDateTime(dtRow["call_timestamp"]);
                if (ColContain(dt, dtRow, "call_status"))
                    objCalling.CallStatus = Convert.ToInt32(dtRow["call_status"]);
                if (ColContain(dt, dtRow, "organization_id"))
                    objCalling.OrganizationId = Convert.ToInt32(dtRow["organization_id"]);

                if (ColContain(dt, dtRow, "is_soft_locked"))
                    objCalling.IsSoftLocked = Convert.ToBoolean(dtRow["is_soft_locked"]);
                if (ColContain(dt, dtRow, "soft_locked_by"))
                    objCalling.SoftLockedBy = Convert.ToInt32(dtRow["soft_locked_by"]);
                if (ColContain(dt, dtRow, "soft_lock_timestamp"))
                    objCalling.SoftLockTimestamp = Convert.ToDateTime(dtRow["soft_lock_timestamp"]);
                if (ColContain(dt, dtRow, "is_hard_locked"))
                    objCalling.IsHardLocked = Convert.ToBoolean(dtRow["is_hard_locked"]);
                if (ColContain(dt, dtRow, "hard_locked_by"))
                    objCalling.HardLockedBy = Convert.ToInt32(dtRow["hard_locked_by"]);
                if (ColContain(dt, dtRow, "hard_lock_timestamp"))
                    objCalling.HardLockTimestamp = Convert.ToDateTime(dtRow["hard_lock_timestamp"]);
                if (ColContain(dt, dtRow, "create_timestamp"))
                    objCalling.CreateTimestamp = Convert.ToDateTime(dtRow["create_timestamp"]);
                if (ColContain(dt, dtRow, "created_by"))
                    objCalling.CreatedBy = Convert.ToInt32(dtRow["created_by"]);
                if (ColContain(dt, dtRow, "modified_timestamp"))
                    objCalling.ModifiedTimestamp = Convert.ToDateTime(dtRow["modified_timestamp"]);
                if (ColContain(dt, dtRow, "modified_by"))
                    objCalling.ModifiedBy = Convert.ToInt32(dtRow["modified_by"]);
                if (ColContain(dt, dtRow, "delete_flag"))
                    objCalling.DeleteFlag = Convert.ToBoolean(dtRow["delete_flag"]);

                lstCCalling.Add(objCalling);
            }
            return lstCCalling;
        }

        public static List<CCandidate> ConvertToListFromDataTableCandidate(this DataTable dt)
        {
            List<CCandidate> lstCCandidateInfo = new List<CCandidate>();

            foreach (DataRow dtRow in dt.Rows)
            {
                CCandidate objCCandidate = new CCandidate();
                if (ColContain(dt, dtRow, "candidate_id"))
                    objCCandidate.CandidateId = Convert.ToInt32(dtRow["candidate_id"]);
                if (ColContain(dt, dtRow, "first_name"))
                    objCCandidate.FirstName = dtRow["first_name"].ToString();
                if (ColContain(dt, dtRow, "middle_name"))
                    objCCandidate.MiddleName = dtRow["middle_name"].ToString();
                if (ColContain(dt, dtRow, "last_name"))
                    objCCandidate.LastName = dtRow["last_name"].ToString();
                if (ColContain(dt, dtRow, "contact_address"))
                    objCCandidate.ContactAddress = dtRow["contact_address"].ToString();
                if (ColContain(dt, dtRow, "email_id"))
                    objCCandidate.EmailId = dtRow["email_id"].ToString();
                if (ColContain(dt, dtRow, "mobile"))
                    objCCandidate.Mobile = dtRow["mobile"].ToString();
                if (ColContain(dt, dtRow, "landline"))
                    objCCandidate.Landline = dtRow["landline"].ToString();
                if (ColContain(dt, dtRow, "source"))
                    objCCandidate.Source = Convert.ToInt32(dtRow["source"]);
                if (ColContain(dt, dtRow, "reference_by"))
                    objCCandidate.ReferenceBy = dtRow["reference_by"].ToString();
                if (ColContain(dt, dtRow, "department"))
                    objCCandidate.Department = Convert.ToInt32(dtRow["department"]);
                if (ColContain(dt, dtRow, "skills"))
                    objCCandidate.Skills = dtRow["skills"].ToString();
                if (ColContain(dt, dtRow, "expirence"))
                    objCCandidate.Expirence = Convert.ToInt32(dtRow["expirence"]);
                //if (ColContain(dt, dtRow, "resume"))
                    //File stream object
                if (ColContain(dt, dtRow, "is_soft_locked"))
                    objCCandidate.IsSoftLocked = Convert.ToBoolean(dtRow["is_soft_locked"]);
                if (ColContain(dt, dtRow, "soft_locked_by"))
                    objCCandidate.SoftLockedBy = Convert.ToInt32(dtRow["soft_locked_by"]);
                if (ColContain(dt, dtRow, "soft_lock_timestamp"))
                    objCCandidate.SoftLockTimestamp = Convert.ToDateTime(dtRow["soft_lock_timestamp"]);
                if (ColContain(dt, dtRow, "is_hard_locked"))
                    objCCandidate.IsHardLocked = Convert.ToBoolean(dtRow["is_hard_locked"]);
                if (ColContain(dt, dtRow, "hard_locked_by"))
                    objCCandidate.HardLockedBy = Convert.ToInt32(dtRow["hard_locked_by"]);
                if (ColContain(dt, dtRow, "hard_lock_timestamp"))
                    objCCandidate.HardLockTimestamp = Convert.ToDateTime(dtRow["hard_lock_timestamp"]);
                if (ColContain(dt, dtRow, "create_timestamp"))
                    objCCandidate.CreateTimestamp = Convert.ToDateTime(dtRow["create_timestamp"]);
                if (ColContain(dt, dtRow, "created_by"))
                    objCCandidate.CreatedBy = Convert.ToInt32(dtRow["created_by"]);
                if (ColContain(dt, dtRow, "modified_timestamp"))
                    objCCandidate.ModifiedTimestamp = Convert.ToDateTime(dtRow["modified_timestamp"]);
                if (ColContain(dt, dtRow, "modified_by"))
                    objCCandidate.ModifiedBy = Convert.ToInt32(dtRow["modified_by"]);
                if (ColContain(dt, dtRow, "delete_flag"))
                    objCCandidate.DeleteFlag = Convert.ToBoolean(dtRow["delete_flag"]);

                lstCCandidateInfo.Add(objCCandidate);
            }
            return lstCCandidateInfo;
        }

        public static List<CCandidateDriveStatus> ConvertToListFromDataTableCandidateDriveStatus(this DataTable dt)
        {
            List<CCandidateDriveStatus> lstCCandidateDriveStatus = new List<CCandidateDriveStatus>();

            foreach (DataRow dtRow in dt.Rows)
            {
                CCandidateDriveStatus objCandidateDriveStatus = new CCandidateDriveStatus();

                if (ColContain(dt, dtRow, "candidate_drive_status_id"))
                    objCandidateDriveStatus.CandidateDriveStatusId = Convert.ToInt32(dtRow["candidate_drive_status_id"]);
                if (ColContain(dt, dtRow, "organization_id"))
                    objCandidateDriveStatus.OrganizationId = Convert.ToInt32(dtRow["organization_id"]);

                if (ColContain(dt, dtRow, "candidate_drive_status_name"))
                    objCandidateDriveStatus.CandidateDriveStatusName = dtRow["candidate_drive_status_name"].ToString();
                if (ColContain(dt, dtRow, "candidate_drive_status_desc"))
                    objCandidateDriveStatus.CandidateDriveStatusDesc = dtRow["candidate_drive_status_desc"].ToString();
                if (ColContain(dt, dtRow, "is_soft_locked"))
                    objCandidateDriveStatus.IsSoftLocked = Convert.ToBoolean(dtRow["is_soft_locked"]);
                if (ColContain(dt, dtRow, "soft_locked_by"))
                    objCandidateDriveStatus.SoftLockedBy = Convert.ToInt32(dtRow["soft_locked_by"]);
                if (ColContain(dt, dtRow, "soft_lock_timestamp"))
                    objCandidateDriveStatus.SoftLockTimestamp = Convert.ToDateTime(dtRow["soft_lock_timestamp"]);
                if (ColContain(dt, dtRow, "is_hard_locked"))
                    objCandidateDriveStatus.IsHardLocked = Convert.ToBoolean(dtRow["is_hard_locked"]);
                if (ColContain(dt, dtRow, "hard_locked_by"))
                    objCandidateDriveStatus.HardLockedBy = Convert.ToInt32(dtRow["hard_locked_by"]);
                if (ColContain(dt, dtRow, "hard_lock_timestamp"))
                    objCandidateDriveStatus.HardLockTimestamp = Convert.ToDateTime(dtRow["hard_lock_timestamp"]);
                if (ColContain(dt, dtRow, "create_timestamp"))
                    objCandidateDriveStatus.CreateTimestamp = Convert.ToDateTime(dtRow["create_timestamp"]);
                if (ColContain(dt, dtRow, "created_by"))
                    objCandidateDriveStatus.CreatedBy = Convert.ToInt32(dtRow["created_by"]);
                if (ColContain(dt, dtRow, "modified_timestamp"))
                    objCandidateDriveStatus.ModifiedTimestamp = Convert.ToDateTime(dtRow["modified_timestamp"]);
                if (ColContain(dt, dtRow, "modified_by"))
                    objCandidateDriveStatus.ModifiedBy = Convert.ToInt32(dtRow["modified_by"]);
                if (ColContain(dt, dtRow, "delete_flag"))
                    objCandidateDriveStatus.DeleteFlag = Convert.ToBoolean(dtRow["delete_flag"]);

                lstCCandidateDriveStatus.Add(objCandidateDriveStatus);

            }
            return lstCCandidateDriveStatus;
        }

        public static List<CCandidateSource> ConvertToListFromDataTableCandidateSource(this DataTable dt)
        {
            List<CCandidateSource> lstCCandidateSource = new List<CCandidateSource>();

            foreach (DataRow dtRow in dt.Rows)
            {
                CCandidateSource objCCandidateSource = new CCandidateSource();

                if (ColContain(dt, dtRow, "candidate_source_id"))
                    objCCandidateSource.CandidateSourceId = Convert.ToInt32(dtRow["candidate_source_id"]);
                if (ColContain(dt, dtRow, "organization_id"))
                    objCCandidateSource.OrganizationId = Convert.ToInt32(dtRow["organization_id"]);
                if (ColContain(dt, dtRow, "candidate_source_name"))
                    objCCandidateSource.CandidateSourceName = dtRow["candidate_source_name"].ToString();
                if (ColContain(dt, dtRow, "candidate_source_desc"))
                    objCCandidateSource.CandidateSourceDesc = dtRow["candidate_source_desc"].ToString();
                if (ColContain(dt, dtRow, "is_soft_locked"))
                    objCCandidateSource.IsSoftLocked = Convert.ToBoolean(dtRow["is_soft_locked"]);
                if (ColContain(dt, dtRow, "soft_locked_by"))
                    objCCandidateSource.SoftLockedBy = Convert.ToInt32(dtRow["soft_locked_by"]);
                if (ColContain(dt, dtRow, "soft_lock_timestamp"))
                    objCCandidateSource.SoftLockTimestamp = Convert.ToDateTime(dtRow["soft_lock_timestamp"]);
                if (ColContain(dt, dtRow, "is_hard_locked"))
                    objCCandidateSource.IsHardLocked = Convert.ToBoolean(dtRow["is_hard_locked"]);
                if (ColContain(dt, dtRow, "hard_locked_by"))
                    objCCandidateSource.HardLockedBy = Convert.ToInt32(dtRow["hard_locked_by"]);
                if (ColContain(dt, dtRow, "hard_lock_timestamp"))
                    objCCandidateSource.HardLockTimestamp = Convert.ToDateTime(dtRow["hard_lock_timestamp"]);
                if (ColContain(dt, dtRow, "create_timestamp"))
                    objCCandidateSource.CreateTimestamp = Convert.ToDateTime(dtRow["create_timestamp"]);
                if (ColContain(dt, dtRow, "created_by"))
                    objCCandidateSource.CreatedBy = Convert.ToInt32(dtRow["created_by"]);
                if (ColContain(dt, dtRow, "modified_timestamp"))
                    objCCandidateSource.ModifiedTimestamp = Convert.ToDateTime(dtRow["modified_timestamp"]);
                if (ColContain(dt, dtRow, "modified_by"))
                    objCCandidateSource.ModifiedBy = Convert.ToInt32(dtRow["modified_by"]);
                if (ColContain(dt, dtRow, "delete_flag"))
                    objCCandidateSource.DeleteFlag = Convert.ToBoolean(dtRow["delete_flag"]);

                lstCCandidateSource.Add(objCCandidateSource);

            }
            return lstCCandidateSource;
        }

        public static List<CClient> ConvertToListFromDataTableClient(this DataTable dt)
        {
            List<CClient> lstCClient = new List<CClient>();

            foreach (DataRow dtRow in dt.Rows)
            {
                CClient objCClient = new CClient();

                if (ColContain(dt, dtRow, "client_id"))
                    objCClient.ClientId = Convert.ToInt32(dtRow["client_id"]);
                if (ColContain(dt, dtRow, "organization_id"))
                    objCClient.OrganizationId = Convert.ToInt32(dtRow["organization_id"]);
                if (ColContain(dt, dtRow, "client_name"))
                    objCClient.ClientName = dtRow["client_name"].ToString();
                if (ColContain(dt, dtRow, "client_desc"))
                    objCClient.ClientDesc = dtRow["client_desc"].ToString();
                if (ColContain(dt, dtRow, "contact_address"))
                    objCClient.ContactAddress = dtRow["contact_address"].ToString();
                if (ColContain(dt, dtRow, "client_logo"))
                    objCClient.ClientLogo = dtRow["client_logo"].ToString();
                if (ColContain(dt, dtRow, "website"))
                    objCClient.Website = dtRow["website"].ToString();
                if (ColContain(dt, dtRow, "industry"))
                    objCClient.Industry = dtRow["industry"].ToString();
                if (ColContain(dt, dtRow, "client_manager"))
                    objCClient.ClientManager = dtRow["client_manager"].ToString();
                if (ColContain(dt, dtRow, "contract_doc"))
                    objCClient.ContractDoc = dtRow["contract_doc"].ToString();
                if (ColContain(dt, dtRow, "is_soft_locked"))
                    objCClient.IsSoftLocked = Convert.ToBoolean(dtRow["is_soft_locked"]);
                if (ColContain(dt, dtRow, "soft_locked_by"))
                    objCClient.SoftLockedBy = Convert.ToInt32(dtRow["soft_locked_by"]);
                if (ColContain(dt, dtRow, "soft_lock_timestamp"))
                    objCClient.SoftLockTimestamp = Convert.ToDateTime(dtRow["soft_lock_timestamp"]);
                if (ColContain(dt, dtRow, "is_hard_locked"))
                    objCClient.IsHardLocked = Convert.ToBoolean(dtRow["is_hard_locked"]);
                if (ColContain(dt, dtRow, "hard_locked_by"))
                    objCClient.HardLockedBy = Convert.ToInt32(dtRow["hard_locked_by"]);
                if (ColContain(dt, dtRow, "hard_lock_timestamp"))
                    objCClient.HardLockTimestamp = Convert.ToDateTime(dtRow["hard_lock_timestamp"]);
                if (ColContain(dt, dtRow, "create_timestamp"))
                    objCClient.CreateTimestamp = Convert.ToDateTime(dtRow["create_timestamp"]);
                if (ColContain(dt, dtRow, "created_by"))
                    objCClient.CreatedBy = Convert.ToInt32(dtRow["created_by"]);
                if (ColContain(dt, dtRow, "modified_timestamp"))
                    objCClient.ModifiedTimestamp = Convert.ToDateTime(dtRow["modified_timestamp"]);
                if (ColContain(dt, dtRow, "modified_by"))
                    objCClient.ModifiedBy = Convert.ToInt32(dtRow["modified_by"]);
                if (ColContain(dt, dtRow, "delete_flag"))
                    objCClient.DeleteFlag = Convert.ToBoolean(dtRow["delete_flag"]);

                lstCClient.Add(objCClient);

            }
            return lstCClient;
        }

        public static List<CContactPerson> ConvertToListFromDataTableContactPerson(this DataTable dt)
        {
            List<CContactPerson> lstCContactPerson = new List<CContactPerson>();

            foreach (DataRow dtRow in dt.Rows)
            {
                CContactPerson objCContactPerson = new CContactPerson();

                if (ColContain(dt, dtRow, "contact_person_id"))
                    objCContactPerson.ContactPersonId = Convert.ToInt32(dtRow["contact_person_id"]);
                if (ColContain(dt, dtRow, "client_id"))
                    objCContactPerson.ClientId = Convert.ToInt32(dtRow["client_id"]);
                if (ColContain(dt, dtRow, "contact_person_name"))
                    objCContactPerson.ContactPersonName = dtRow["contact_person_name"].ToString();
                if (ColContain(dt, dtRow, "contact_number"))
                    objCContactPerson.ContactNumber = dtRow["contact_number"].ToString();
                if (ColContain(dt, dtRow, "contact_email"))
                    objCContactPerson.ContactEmail = dtRow["contact_email"].ToString();
                if (ColContain(dt, dtRow, "designation"))
                    objCContactPerson.Designation = dtRow["designation"].ToString();
                if (ColContain(dt, dtRow, "is_soft_locked"))
                    objCContactPerson.IsSoftLocked = Convert.ToBoolean(dtRow["is_soft_locked"]);
                if (ColContain(dt, dtRow, "soft_locked_by"))
                    objCContactPerson.SoftLockedBy = Convert.ToInt32(dtRow["soft_locked_by"]);
                if (ColContain(dt, dtRow, "soft_lock_timestamp"))
                    objCContactPerson.SoftLockTimestamp = Convert.ToDateTime(dtRow["soft_lock_timestamp"]);
                if (ColContain(dt, dtRow, "is_hard_locked"))
                    objCContactPerson.IsHardLocked = Convert.ToBoolean(dtRow["is_hard_locked"]);
                if (ColContain(dt, dtRow, "hard_locked_by"))
                    objCContactPerson.HardLockedBy = Convert.ToInt32(dtRow["hard_locked_by"]);
                if (ColContain(dt, dtRow, "hard_lock_timestamp"))
                    objCContactPerson.HardLockTimestamp = Convert.ToDateTime(dtRow["hard_lock_timestamp"]);
                if (ColContain(dt, dtRow, "create_timestamp"))
                    objCContactPerson.CreateTimestamp = Convert.ToDateTime(dtRow["create_timestamp"]);
                if (ColContain(dt, dtRow, "created_by"))
                    objCContactPerson.CreatedBy = Convert.ToInt32(dtRow["created_by"]);
                if (ColContain(dt, dtRow, "modified_timestamp"))
                    objCContactPerson.ModifiedTimestamp = Convert.ToDateTime(dtRow["modified_timestamp"]);
                if (ColContain(dt, dtRow, "modified_by"))
                    objCContactPerson.ModifiedBy = Convert.ToInt32(dtRow["modified_by"]);
                if (ColContain(dt, dtRow, "delete_flag"))
                    objCContactPerson.DeleteFlag = Convert.ToBoolean(dtRow["delete_flag"]);

                lstCContactPerson.Add(objCContactPerson);
            }
            return lstCContactPerson;
        }

         public static List<CShift> ConvertToListFromDataTableShift(this DataTable dt)
        {
            List<CShift> lstCShift = new List<CShift>();

            foreach (DataRow dtRow in dt.Rows)
            {
                CShift objCShift = new CShift();

                if (ColContain(dt, dtRow, "shift_id"))
                    objCShift.ShiftId = Convert.ToInt32(dtRow["shift_id"]);
                if (ColContain(dt, dtRow, "organization_id"))
                    objCShift.OrganizationId = Convert.ToInt32(dtRow["organization_id"]);
                if (ColContain(dt, dtRow, "shift_name"))
                    objCShift.ShiftName = dtRow["shift_name"].ToString();
                if (ColContain(dt, dtRow, "shift_desc"))
                    objCShift.ShiftDesc = dtRow["shift_desc"].ToString();
                if (ColContain(dt, dtRow, "shift_start_time"))
                    objCShift.ShiftStartTime = DateTime.Parse(dtRow["shift_start_time"].ToString());
                if (ColContain(dt, dtRow, "shift_end_time"))
                    objCShift.ShiftEndTime = DateTime.Parse(dtRow["shift_end_time"].ToString());
                if (ColContain(dt, dtRow, "is_soft_locked"))
                    objCShift.IsSoftLocked = Convert.ToBoolean(dtRow["is_soft_locked"]);
                if (ColContain(dt, dtRow, "soft_locked_by"))
                    objCShift.SoftLockedBy = Convert.ToInt32(dtRow["soft_locked_by"]);
                if (ColContain(dt, dtRow, "soft_lock_timestamp"))
                    objCShift.SoftLockTimestamp = Convert.ToDateTime(dtRow["soft_lock_timestamp"]);
                if (ColContain(dt, dtRow, "is_hard_locked"))
                    objCShift.IsHardLocked = Convert.ToBoolean(dtRow["is_hard_locked"]);
                if (ColContain(dt, dtRow, "hard_locked_by"))
                    objCShift.HardLockedBy = Convert.ToInt32(dtRow["hard_locked_by"]);
                if (ColContain(dt, dtRow, "hard_lock_timestamp"))
                    objCShift.HardLockTimestamp = Convert.ToDateTime(dtRow["hard_lock_timestamp"]);
                if (ColContain(dt, dtRow, "create_timestamp"))
                    objCShift.CreateTimestamp = Convert.ToDateTime(dtRow["create_timestamp"]);
                if (ColContain(dt, dtRow, "created_by"))
                    objCShift.CreatedBy = Convert.ToInt32(dtRow["created_by"]);
                if (ColContain(dt, dtRow, "modified_timestamp"))
                    objCShift.ModifiedTimestamp = Convert.ToDateTime(dtRow["modified_timestamp"]);
                if (ColContain(dt, dtRow, "modified_by"))
                    objCShift.ModifiedBy = Convert.ToInt32(dtRow["modified_by"]);
                if (ColContain(dt, dtRow, "delete_flag"))
                    objCShift.DeleteFlag = Convert.ToBoolean(dtRow["delete_flag"]);

                lstCShift.Add(objCShift);

            }
            return lstCShift;
        }

         public static List<CVacancy> ConvertToListFromDataTableVacancy(this DataTable dt)
         {
             List<CVacancy> lstCVacancy = new List<CVacancy>();

             foreach (DataRow dtRow in dt.Rows)
             {
                 CVacancy objCVacancy = new CVacancy();

                 if (ColContain(dt, dtRow, "vacancy_id"))
                     objCVacancy.VacancyId = Convert.ToInt32(dtRow["vacancy_id"]);
                 if (ColContain(dt, dtRow, "organization_id"))
                     objCVacancy.OrganizationId = Convert.ToInt32(dtRow["organization_id"]);
                 if (ColContain(dt, dtRow, "vacancy_name"))
                     objCVacancy.VacancyName = dtRow["vacancy_name"].ToString();
                 if (ColContain(dt, dtRow, "client_id"))
                     objCVacancy.ClientId = Convert.ToInt32(dtRow["client_id"]);
                 if (ColContain(dt, dtRow, "opening_date"))
                     objCVacancy.OpeningDate = Convert.ToDateTime(dtRow["opening_date"]);
                 if (ColContain(dt, dtRow, "department"))
                     objCVacancy.Department = Convert.ToInt32(dtRow["department"]);
                 if (ColContain(dt, dtRow, "vacancy_desc"))
                     objCVacancy.VacancyDesc = dtRow["vacancy_desc"].ToString();
                 if (ColContain(dt, dtRow, "shift"))
                     objCVacancy.Shift = Convert.ToInt32(dtRow["shift"]);
                 if (ColContain(dt, dtRow, "status"))
                     objCVacancy.Status = Convert.ToInt32(dtRow["status"]);
                 if (ColContain(dt, dtRow, "allocated_to"))
                     objCVacancy.AllocatedTo = Convert.ToInt32(dtRow["allocated_to"]);
                 if (ColContain(dt, dtRow, "technical_skills"))
                     objCVacancy.TechnicalSkills = dtRow["technical_skills"].ToString();
                 if (ColContain(dt, dtRow, "keywords"))
                     objCVacancy.Keywords = dtRow["keywords"].ToString();
                 if (ColContain(dt, dtRow, "expirence_range"))
                     objCVacancy.ExpirenceRange = Convert.ToInt32(dtRow["expirence_range"]);
                 if (ColContain(dt, dtRow, "salary_range"))
                     objCVacancy.SalaryRange = Convert.ToInt32(dtRow["salary_range"]);
                 if (ColContain(dt, dtRow, "notice_period_days"))
                     objCVacancy.NoticePeriodDays = Convert.ToInt32(dtRow["notice_period_days"]);
                 if (ColContain(dt, dtRow, "roles_responsibilities"))
                     objCVacancy.RolesResponsibilities = dtRow["roles_responsibilities"].ToString();
                 if (ColContain(dt, dtRow, "is_soft_locked"))
                     objCVacancy.IsSoftLocked = Convert.ToBoolean(dtRow["is_soft_locked"]);
                 if (ColContain(dt, dtRow, "soft_locked_by"))
                     objCVacancy.SoftLockedBy = Convert.ToInt32(dtRow["soft_locked_by"]);
                 if (ColContain(dt, dtRow, "soft_lock_timestamp"))
                     objCVacancy.SoftLockTimestamp = Convert.ToDateTime(dtRow["soft_lock_timestamp"]);
                 if (ColContain(dt, dtRow, "is_hard_locked"))
                     objCVacancy.IsHardLocked = Convert.ToBoolean(dtRow["is_hard_locked"]);
                 if (ColContain(dt, dtRow, "hard_locked_by"))
                     objCVacancy.HardLockedBy = Convert.ToInt32(dtRow["hard_locked_by"]);
                 if (ColContain(dt, dtRow, "hard_lock_timestamp"))
                     objCVacancy.HardLockTimestamp = Convert.ToDateTime(dtRow["hard_lock_timestamp"]);
                 if (ColContain(dt, dtRow, "create_timestamp"))
                     objCVacancy.CreateTimestamp = Convert.ToDateTime(dtRow["create_timestamp"]);
                 if (ColContain(dt, dtRow, "created_by"))
                     objCVacancy.CreatedBy = Convert.ToInt32(dtRow["created_by"]);
                 if (ColContain(dt, dtRow, "modified_timestamp"))
                     objCVacancy.ModifiedTimestamp = Convert.ToDateTime(dtRow["modified_timestamp"]);
                 if (ColContain(dt, dtRow, "modified_by"))
                     objCVacancy.ModifiedBy = Convert.ToInt32(dtRow["modified_by"]);
                 if (ColContain(dt, dtRow, "delete_flag"))
                     objCVacancy.DeleteFlag = Convert.ToBoolean(dtRow["delete_flag"]);

                 lstCVacancy.Add(objCVacancy);

             }
             return lstCVacancy;
         }

         public static List<CVacancyStatus> ConvertToListFromDataTableVacancyStatus(this DataTable dt)
         {
             List<CVacancyStatus> lstCVacancyStatus = new List<CVacancyStatus>();

             foreach (DataRow dtRow in dt.Rows)
             {
                 CVacancyStatus objCVacancyStatus = new CVacancyStatus();

                 if (ColContain(dt, dtRow, "vacancy_status_id"))
                     objCVacancyStatus.VacancyStatusId = Convert.ToInt32(dtRow["vacancy_status_id"]);
                 if (ColContain(dt, dtRow, "organization_id"))
                     objCVacancyStatus.OrganizationId = Convert.ToInt32(dtRow["organization_id"]);
                 if (ColContain(dt, dtRow, "vacancy_status_name"))
                     objCVacancyStatus.VacancyStatusName = dtRow["vacancy_status_name"].ToString();
                 if (ColContain(dt, dtRow, "client_id"))
                     objCVacancyStatus.ClientId = Convert.ToInt32(dtRow["client_id"]);
                 if (ColContain(dt, dtRow, "vacancy_status_desc"))
                     objCVacancyStatus.VacancyStatusDesc = dtRow["vacancy_status_desc"].ToString();
                 if (ColContain(dt, dtRow, "is_soft_locked"))
                     objCVacancyStatus.IsSoftLocked = Convert.ToBoolean(dtRow["is_soft_locked"]);
                 if (ColContain(dt, dtRow, "soft_locked_by"))
                     objCVacancyStatus.SoftLockedBy = Convert.ToInt32(dtRow["soft_locked_by"]);
                 if (ColContain(dt, dtRow, "soft_lock_timestamp"))
                     objCVacancyStatus.SoftLockTimestamp = Convert.ToDateTime(dtRow["soft_lock_timestamp"]);
                 if (ColContain(dt, dtRow, "is_hard_locked"))
                     objCVacancyStatus.IsHardLocked = Convert.ToBoolean(dtRow["is_hard_locked"]);
                 if (ColContain(dt, dtRow, "hard_locked_by"))
                     objCVacancyStatus.HardLockedBy = Convert.ToInt32(dtRow["hard_locked_by"]);
                 if (ColContain(dt, dtRow, "hard_lock_timestamp"))
                     objCVacancyStatus.HardLockTimestamp = Convert.ToDateTime(dtRow["hard_lock_timestamp"]);
                 if (ColContain(dt, dtRow, "create_timestamp"))
                     objCVacancyStatus.CreateTimestamp = Convert.ToDateTime(dtRow["create_timestamp"]);
                 if (ColContain(dt, dtRow, "created_by"))
                     objCVacancyStatus.CreatedBy = Convert.ToInt32(dtRow["created_by"]);
                 if (ColContain(dt, dtRow, "modified_timestamp"))
                     objCVacancyStatus.ModifiedTimestamp = Convert.ToDateTime(dtRow["modified_timestamp"]);
                 if (ColContain(dt, dtRow, "modified_by"))
                     objCVacancyStatus.ModifiedBy = Convert.ToInt32(dtRow["modified_by"]);
                 if (ColContain(dt, dtRow, "delete_flag"))
                     objCVacancyStatus.DeleteFlag = Convert.ToBoolean(dtRow["delete_flag"]);

                 lstCVacancyStatus.Add(objCVacancyStatus);

             }
             return lstCVacancyStatus;
         }

         public static List<CVacancySalary> ConvertToListFromDataTableVacancySalary(this DataTable dt)
         {
             List<CVacancySalary> lstVacancySalary = new List<CVacancySalary>();

             foreach (DataRow dtRow in dt.Rows)
             {
                 CVacancySalary objCVacancySalary = new CVacancySalary();

                 if (ColContain(dt, dtRow, "vacancy_salary_id"))
                     objCVacancySalary.VacancySalaryId = Convert.ToInt32(dtRow["vacancy_salary_id"]);
                 if (ColContain(dt, dtRow, "organization_id"))
                     objCVacancySalary.OrganizationId = Convert.ToInt32(dtRow["organization_id"]);
                 if (ColContain(dt, dtRow, "vacancy_salary_name"))
                     objCVacancySalary.VacancySalaryName = dtRow["vacancy_salary_name"].ToString();
                 if (ColContain(dt, dtRow, "client_id"))
                     objCVacancySalary.ClientId = Convert.ToInt32(dtRow["client_id"]);
                 if (ColContain(dt, dtRow, "min_salary_annual"))
                     objCVacancySalary.MinSalaryAnnual = Convert.ToInt32(dtRow["min_salary_annual"]);
                 if (ColContain(dt, dtRow, "max_salary_annual"))
                     objCVacancySalary.MaxSalaryAnnual = Convert.ToInt32(dtRow["max_salary_annual"]);
                 if (ColContain(dt, dtRow, "vacancy_salary_desc"))
                     objCVacancySalary.VacancySalaryDesc = dtRow["vacancy_salary_desc"].ToString();
                 if (ColContain(dt, dtRow, "is_soft_locked"))
                     objCVacancySalary.IsSoftLocked = Convert.ToBoolean(dtRow["is_soft_locked"]);
                 if (ColContain(dt, dtRow, "soft_locked_by"))
                     objCVacancySalary.SoftLockedBy = Convert.ToInt32(dtRow["soft_locked_by"]);
                 if (ColContain(dt, dtRow, "soft_lock_timestamp"))
                     objCVacancySalary.SoftLockTimestamp = Convert.ToDateTime(dtRow["soft_lock_timestamp"]);
                 if (ColContain(dt, dtRow, "is_hard_locked"))
                     objCVacancySalary.IsHardLocked = Convert.ToBoolean(dtRow["is_hard_locked"]);
                 if (ColContain(dt, dtRow, "hard_locked_by"))
                     objCVacancySalary.HardLockedBy = Convert.ToInt32(dtRow["hard_locked_by"]);
                 if (ColContain(dt, dtRow, "hard_lock_timestamp"))
                     objCVacancySalary.HardLockTimestamp = Convert.ToDateTime(dtRow["hard_lock_timestamp"]);
                 if (ColContain(dt, dtRow, "create_timestamp"))
                     objCVacancySalary.CreateTimestamp = Convert.ToDateTime(dtRow["create_timestamp"]);
                 if (ColContain(dt, dtRow, "created_by"))
                     objCVacancySalary.CreatedBy = Convert.ToInt32(dtRow["created_by"]);
                 if (ColContain(dt, dtRow, "modified_timestamp"))
                     objCVacancySalary.ModifiedTimestamp = Convert.ToDateTime(dtRow["modified_timestamp"]);
                 if (ColContain(dt, dtRow, "modified_by"))
                     objCVacancySalary.ModifiedBy = Convert.ToInt32(dtRow["modified_by"]);
                 if (ColContain(dt, dtRow, "delete_flag"))
                     objCVacancySalary.DeleteFlag = Convert.ToBoolean(dtRow["delete_flag"]);

                 lstVacancySalary.Add(objCVacancySalary);

             }
             return lstVacancySalary;
         }

         public static List<CVacancyExpirence> ConvertToListFromDataTableVacancyExpirence(this DataTable dt)
         {
             List<CVacancyExpirence> lstVacancyExpirence = new List<CVacancyExpirence>();

             foreach (DataRow dtRow in dt.Rows)
             {
                 CVacancyExpirence objCVacancyExpirence = new CVacancyExpirence();

                 if (ColContain(dt, dtRow, "vacancy_expirence_id"))
                     objCVacancyExpirence.VacancyExpirenceId = Convert.ToInt32(dtRow["vacancy_expirence_id"]);
                 if (ColContain(dt, dtRow, "organization_id"))
                     objCVacancyExpirence.OrganizationId = Convert.ToInt32(dtRow["organization_id"]);
                 if (ColContain(dt, dtRow, "vacancy_expirence_name"))
                     objCVacancyExpirence.VacancyExpirenceName = dtRow["vacancy_expirence_name"].ToString();
                 if (ColContain(dt, dtRow, "client_id"))
                     objCVacancyExpirence.ClientId = Convert.ToInt32(dtRow["client_id"]);
                 if (ColContain(dt, dtRow, "vacancy_expirence_desc"))
                     objCVacancyExpirence.VacancyExpirenceDesc = dtRow["vacancy_expirence_desc"].ToString();
                 if (ColContain(dt, dtRow, "min_expirence_years"))
                     objCVacancyExpirence.MinExpirenceYears = Convert.ToInt32(dtRow["min_expirence_years"]);
                 if (ColContain(dt, dtRow, "min_expirence_months"))
                     objCVacancyExpirence.MinExpirenceMonths = Convert.ToInt32(dtRow["min_expirence_months"]);
                 if (ColContain(dt, dtRow, "max_expirence_years"))
                     objCVacancyExpirence.MaxExpirenceYears = Convert.ToInt32(dtRow["max_expirence_years"]);
                 if (ColContain(dt, dtRow, "max_expirence_months"))
                     objCVacancyExpirence.MaxExpirenceMonths = Convert.ToInt32(dtRow["max_expirence_months"]);
                 if (ColContain(dt, dtRow, "is_soft_locked"))
                     objCVacancyExpirence.IsSoftLocked = Convert.ToBoolean(dtRow["is_soft_locked"]);
                 if (ColContain(dt, dtRow, "soft_locked_by"))
                     objCVacancyExpirence.SoftLockedBy = Convert.ToInt32(dtRow["soft_locked_by"]);
                 if (ColContain(dt, dtRow, "soft_lock_timestamp"))
                     objCVacancyExpirence.SoftLockTimestamp = Convert.ToDateTime(dtRow["soft_lock_timestamp"]);
                 if (ColContain(dt, dtRow, "is_hard_locked"))
                     objCVacancyExpirence.IsHardLocked = Convert.ToBoolean(dtRow["is_hard_locked"]);
                 if (ColContain(dt, dtRow, "hard_locked_by"))
                     objCVacancyExpirence.HardLockedBy = Convert.ToInt32(dtRow["hard_locked_by"]);
                 if (ColContain(dt, dtRow, "hard_lock_timestamp"))
                     objCVacancyExpirence.HardLockTimestamp = Convert.ToDateTime(dtRow["hard_lock_timestamp"]);
                 if (ColContain(dt, dtRow, "create_timestamp"))
                     objCVacancyExpirence.CreateTimestamp = Convert.ToDateTime(dtRow["create_timestamp"]);
                 if (ColContain(dt, dtRow, "created_by"))
                     objCVacancyExpirence.CreatedBy = Convert.ToInt32(dtRow["created_by"]);
                 if (ColContain(dt, dtRow, "modified_timestamp"))
                     objCVacancyExpirence.ModifiedTimestamp = Convert.ToDateTime(dtRow["modified_timestamp"]);
                 if (ColContain(dt, dtRow, "modified_by"))
                     objCVacancyExpirence.ModifiedBy = Convert.ToInt32(dtRow["modified_by"]);
                 if (ColContain(dt, dtRow, "delete_flag"))
                     objCVacancyExpirence.DeleteFlag = Convert.ToBoolean(dtRow["delete_flag"]);

                 lstVacancyExpirence.Add(objCVacancyExpirence);

             }
             return lstVacancyExpirence;
         }

        public static List<T> ToCollection<T>(this DataTable dt)
        {
            List<T> lst = new System.Collections.Generic.List<T>();
            Type tClass = typeof(T);
            PropertyInfo[] pClass = tClass.GetProperties();
            List<DataColumn> dc = dt.Columns.Cast<DataColumn>().ToList();
            T cn;
            foreach (DataRow item in dt.Rows)
            {
                cn = (T)Activator.CreateInstance(tClass);
                foreach (PropertyInfo pc in pClass)
                {
                    // Can comment try catch block. 
                    try
                    {
                        DataColumn d = dc.Find(c => c.ColumnName == pc.Name);
                        if (d != null)
                            pc.SetValue(cn, item[pc.Name], null);
                    }
                    catch
                    {
                    }
                }
                lst.Add(cn);
            }
            return lst;
        }
    }
}